// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

import Global from "../../lib/Global";
import NetMgr, { NetMethod } from "../../lib/net/NetMgr";
import PlatformBase from "../../lib/platform/PlatformBase";


const {ccclass, property} = cc._decorator;

@ccclass
export default class WebPlatform extends PlatformBase {
    public name(): string {
        return "web";
    }
    public login(callback: any): void {
        // let data = {
        //     "uId":100,
        //     "coin":100,
        //     "diamond":100,
        //     "phyNum":10,
        //     "exp":0,
        //     "skin":101,
        //     "time":0,
        //     "killNum":0,
        //     "battleExp":0
        // }
        // callback(data);

        // console.log("账号=====", Global.playerId);
        // let url = Global.isDebug ? Global.localUrl : Global.url;
        // let socketUrl = Global.isDebug ? Global.localSocketUrl : Global.socketUrl;
        // NetMgr.instance.connectHttp(url);
        // NetAdaptation.requestLogin(this.name(), Global.playerId.toString(), function (data) {
        //     NetMgr.instance.connectSocket(socketUrl);
        //     NetMgr.instance.setNetSession(data["gameSessionKey"]);
        //     callback && callback(data);
        // }.bind(this))
        // let data:LoginVerify = {
        //     age:1,
        //     jwt:"wuxiaosheng",
        //     loginBizCode:1
        // }
        // NetMgr.instance.send(ProtocolEnum.SOCKET_LOGIN_VERIFY, encodeLoginVerify(data), function(data:NetPackage){
        //     let userInfo:UserInfo = decodeUserInfo(data.dataContent);
        //     callback && callback(userInfo);
        // }.bind(this), NetMethod.SOCKET);

        callback && callback();
        
    }
}
